package com.lightsh.jbox2d;

import java.util.ArrayList;

import com.lightsh.screens.ObjectTestScreen;
import com.lightsh.screens.PlaneScreen;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleAdapter;

public class ListActivity extends Activity{

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		
		ListView listView = (ListView) findViewById(R.id.listView);
		
		ListAdapter adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, android.R.id.text1, new String[]{
				"测试PhysicsScreen",
				"别人的sample",
				"纸飞机",
				"测试NormalObjectScreen"
		});
		listView.setAdapter(adapter);
		
		listView.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				switch((int)id){
				case 0:
					startActivity(new Intent(ListActivity.this, SurfaceViewActivity.class));
					break;
				case 1:
					startActivity(new Intent(ListActivity.this, MainActivity.class));
					break;
				case 2:{
					Intent intent = new Intent(ListActivity.this, GameActivity.class);
					intent.putExtra(GameActivity.EXTRA_TARGET_SCREEN_NAME, PlaneScreen.class.getName());
					startActivity(intent);
				}
					break;
				case 3:{
					Intent intent = new Intent(ListActivity.this, GameActivity.class);
					intent.putExtra(GameActivity.EXTRA_TARGET_SCREEN_NAME, ObjectTestScreen.class.getName());
					startActivity(intent);
				}
					break;
				}
				
			}
		});
		
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();
		android.os.Process.killProcess(android.os.Process.myPid());
		System.exit(0);
	}
	
}
